package com.lzx.consumer.controller;

import com.lzx.consumer.entity.Demo2;
import com.lzx.consumer.mapper.ConsumerMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 程序员星星
 * @date 2022/12/26
 * @Description
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {
    @Resource
    private ConsumerMapper consumerMapper;

    @GetMapping("/test")
    public Demo2 test() {
        return consumerMapper.selectById(1);
    }

    @PostMapping("/updateData")
    public String updateData() {
        Demo2 demo2 = consumerMapper.selectById(1);
        demo2.setCount(demo2.getCount() - 1);
        consumerMapper.updateById(demo2);
        return "更新成功";
    }
}
